package org.luxor.commons.seata.config;

import io.seata.spring.boot.autoconfigure.SeataAutoConfiguration;
import io.seata.spring.boot.autoconfigure.StarterConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

/**
 * Seata自动配置
 *
 * @author Mr.Yan  @date: 2020/11/27
 * @see SeataAutoConfiguration
 */
@Configuration
@ConditionalOnProperty(prefix = StarterConstants.SEATA_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
public class SeataAutoConfig implements ApplicationContextAware {

    private static final Logger logger = LoggerFactory.getLogger(SeataAutoConfig.class);

    private ApplicationContext applicationContext;

    public SeataAutoConfig() {
        logger.info("init seata config ...");
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
